class BootStrap {

    def init = { servletContext ->
		// Check whether the test data already exists.
		edu.nps.sats.domain.Address address1 = new edu.nps.sats.domain.Address(lineOne:"123 Main St", lineTwo:"", city:"Best", stateOrProvince:"MD",zipCode:"12312", country:"US").save(failOnError: true)
		edu.nps.sats.domain.Address address2 = new edu.nps.sats.domain.Address(lineOne:"456 Main St", lineTwo:"", city:"Best", stateOrProvince:"HI",zipCode:"54544", country:"US").save(failOnError: true)
		edu.nps.sats.domain.Address address3 = new edu.nps.sats.domain.Address(lineOne:"789 Main St", lineTwo:"", city:"Best", stateOrProvince:"TX",zipCode:"76867", country:"US").save(failOnError: true)
		edu.nps.sats.domain.Address address4 = new edu.nps.sats.domain.Address(lineOne:"101 Main St", lineTwo:"", city:"Best", stateOrProvince:"LA",zipCode:"98786", country:"US").save(failOnError: true)
		new edu.nps.sats.domain.Airport(name: "Andrews Airforce Base", code: "AAFB", address: address1).save(failOnError: true)
		new edu.nps.sats.domain.Airport(name: "Hickam Airforce Base", code: "HAFT", address: address2).save(failOnError: true)
		new edu.nps.sats.domain.Airport(name: "MacDill Airforce Base", code: "MAFB", address: address3).save(failOnError: true)
		new edu.nps.sats.domain.Airport(name: "Laughlin Airforce Base", code: "LAFB", address: address4).save(failOnError: true)

		new edu.nps.sats.domain.Airplane(number: "A3242F", seats: 15, airplaneType: edu.nps.sats.domain.AirplaneType.C130).save(failOnError: true);
		new edu.nps.sats.domain.Airplane(number: "C3242S", seats: 25, airplaneType: edu.nps.sats.domain.AirplaneType.KC10).save(failOnError: true);
		new edu.nps.sats.domain.Airplane(number: "23FSD3", seats: 30, airplaneType: edu.nps.sats.domain.AirplaneType.C17).save(failOnError: true);
		new edu.nps.sats.domain.Airplane(number: "3SD52F", seats: 50, airplaneType: edu.nps.sats.domain.AirplaneType.C5).save(failOnError: true);
    }
    def destroy = {
    }
}
